package pref.junx.flybird.activity.fri_msg;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import pref.junx.flybird.R;
import pref.junx.flybird.activity.main.NewMainActivity;
import pref.junx.flybird.base.BaseActicvitylhy;
import pref.junx.flybird.entity.FriendShip;
import pref.junx.flybird.tools.JumpUtil;


/**
 * Created by 半生瓜 on 2017/8/7.
 */

public class Fri_Info_Actvity extends BaseActicvitylhy<Fri_Info_Presenter, Fri_Info_Model> implements Fri_Info_Conteact.View {

    TextView watch_friend_nickname,watch_friend_number,watch_friend_phone,watch_friend_email,finish_fri,watch_friend_sex;
    Button delete,tellphoneing;
    int time,id;
    String callnub;
    @Override
    public int getLayoutId() {
return R.layout.watch_friend_layout;    }

    @Override
    public void initview() {
        finish_fri=(TextView)findViewById(R.id.finish_fri) ;
        watch_friend_nickname=(TextView)findViewById(R.id.watch_friend_nickname) ;
        watch_friend_number=(TextView)findViewById(R.id.watch_friend_number) ;
        watch_friend_phone=(TextView)findViewById(R.id.watch_friend_phone) ;
        watch_friend_email=(TextView)findViewById(R.id.watch_friend_email) ;
        watch_friend_sex=(TextView)findViewById(R.id.watch_friend_sex);
        delete=(Button) findViewById(R.id.watch_friend_deletbutton);
        tellphoneing=(Button) findViewById(R.id.watch_friend_call);
        finish_fri.setOnClickListener(this);
        delete.setOnClickListener(this);
        tellphoneing.setOnClickListener(this);

    }

    @Override
    public void processClick(View view) {
       switch (view.getId()){
           case R.id.finish_fri:
               finish();break;
           case R.id.watch_friend_deletbutton:
               FriendShip friendShip=new FriendShip();
               friendShip.setClaimant_id(String.valueOf(spTools.getInt("user_id")));
               friendShip.setProposer_id(String.valueOf(id));
               presenter.delete(friendShip);break;
           case R.id.watch_friend_call:
               Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+callnub));
               intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               startActivity(intent);
       }
    }


    @Override
    public void init() {
        Intent intent = getIntent();
        id = intent.getIntExtra("id",0);
        callnub=intent.getStringExtra("phone");
        watch_friend_nickname.setText(intent.getStringExtra("nick"));
        watch_friend_number.setText(intent.getStringExtra("number"));
        watch_friend_phone.setText(intent.getStringExtra("phone"));
        watch_friend_email.setText(intent.getStringExtra("email"));
        watch_friend_sex.setText(intent.getStringExtra("sex"));

    }





    @Override
    public void success() {

    }

    @Override
    public void result(String a) {

    }

    @Override
    public void susses() {
        t.show_l("删除成功");
        NewMainActivity.newMainActivity.finish();
        JumpUtil.to(c,NewMainActivity.class);
        finish();
    }

    @Override
    public void fail() {
        t.show_l("删除失败");
        NewMainActivity.newMainActivity.finish();
        JumpUtil.to(c,NewMainActivity.class);
        finish();
    }
}


